package com.googlecode.cswish.security.type;

import java.util.Iterator;

import com.googlecode.cswish.security.Context;


/**
 * @author Jerry.Feng Date: 2008-6-11
 */
public class RecordRuleSetOr extends RuleSetOr implements Calculation {

	@Override
	public String execute(Context context) {
		if (expressList.size() > 0) {
			StringBuilder sb = new StringBuilder();
			for (Iterator<Calculation> iter = expressList.iterator(); iter.hasNext();) {
				Calculation expression = iter.next();
				
				String expressionResult = expression.execute(context);
					
				sb.append(" or (").append(expressionResult).append(")");
			}
			
			// remove the first " or "
			return sb.substring(4);
		} else {
			return "true";
		}
	}
}